package common

import (
	"fmt"
	"strings"

	"engine/PbMsgHelper"
	"engine/db"
	"engine/log"
	"engine/notice/broadcast"
	"gitee.com/ameise84/e3dds"
	time "gitee.com/ameise84/e3time"
	"gitee.com/ameise84/e3utils/str_conv"
	"github.com/spf13/viper"
	"google.golang.org/protobuf/proto"
	"servers/cache"
	"servers/crypto"

	"servers/app/node/api/common/internal"
	"servers/app/node/api/misc"
	"servers/models/db_meta"
	"servers/models/define"
	"servers/models/error_code"
	"servers/models/meta"
	"servers/models/protos/google/pb/rpc_protos"
)

func OnCreateAccount(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	checkFields := []string{
		define.WebBusinessId,
		define.WebAccount,
	}

	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	account := kv[define.WebAccount]
	nickName := "nick_name"

	if !misc.VerifyStringLen(account, define.AccountLen) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	if !misc.VerifyStringLen(nickName, define.NickNameLen) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	info, ok := cache.GetBusinessInfo(str_conv.ToUint32(kv[define.WebBusinessId]))
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy)
		return
	}
	meta := &rpc_protos.AccountMeta{}
	meta.Account = account
	meta.Password = "HttpPassword"
	meta.NickName = nickName
	meta.BusinessID = info.BusinessID
	meta.ScoreType = info.ScoreType
	meta.BagType = info.BagType
	meta.UserType = 0
	meta.UserTag = 0
	rsp := internal.OnCreateAccountReq(&rpc_protos.CreateAccountReq{Account: meta})
	if rsp.Code != error_code.ErrorCodeNoError {
		ResponseFailed(req, rsp.Code)
	} else {
		data := map[string]any{
			define.WebUserId: rsp.UserID,
		}
		ResponseSuccess(req, data)
	}
}

func OnLoginGetToken(behavior e3dds.Behavior, req e3dds.Request, isGuest bool, kv map[string]string) {
	checkFields := []string{
		define.WebAccount,
	}

	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	userID := uint64(0)
	if !isGuest {
		account, ok := kv[define.WebAccount]
		if !ok {
			ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
			return
		}
		userID, ok = cache.GetAccountID(account, str_conv.ToUint32(kv[define.WebBusinessId]))
		if !ok {
			ResponseFailed(req, error_code.ErrorCodeAccountIsNotExist)
			return
		}
	}

	msg := rpc_protos.LoginGetTokenReq{}
	msg.UserID = userID
	msg.IsGuest = isGuest
	rsp := internal.OnLoginGetTokenReq(&msg)

	type SL struct {
		ServerList []string
		HistoryUrl string
	}

	if rsp.Code != error_code.ErrorCodeNoError {
		ResponseFailed(req, rsp.Code)
	} else {
		sl := &SL{
			ServerList: []string{"ws://192.168.77.29:9091"},
		}
		data := map[string]any{
			"token":       rsp.Token,
			"loginConfig": sl,
		}
		ResponseSuccess(req, data)
	}
}

func OnUseBank(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	var (
		SrcOrder  = "order"
		SrcAmount = "amount"
		SrcFlag   = "flag"
		RspScore  = "score"
	)

	checkFields := []string{
		define.WebBusinessId,
		define.WebAccount,
		SrcOrder,
		SrcAmount,
		SrcFlag,
	}

	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	msg := rpc_protos.UseBankReq{}
	msg.Score = str_conv.ToInt64(kv[SrcAmount])
	msg.OrderID = kv[SrcOrder]
	msg.Flag = str_conv.ToBool(kv[SrcFlag])
	if !msg.Flag && msg.Score == 0 {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	ok := false
	msg.UserID, ok = cache.GetAccountID(kv[define.WebAccount], str_conv.ToUint32(kv[define.WebBusinessId]))
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeAccountIsNotExist)
		return
	}

	msg.Timestamp = time.Now().Unix()
	protoc, body := PbMsgHelper.PbMsgToRpcMsg(&msg)
	rsp := e3dds.TakeResponse()
	defer e3dds.FreeResponse(rsp)
	err := behavior.Call(define.ServicePlayer, str_conv.ToString(msg.UserID), protoc, body, rsp)
	if err != nil {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy, err.Error())
		return
	}
	rspMsg := &rpc_protos.UseBankRsp{}
	_ = proto.Unmarshal(rsp.GetBody(), rspMsg)
	data := map[string]any{
		SrcAmount: rspMsg.Score,
		RspScore:  rspMsg.Info.Score,
		SrcOrder:  msg.OrderID,
	}
	ResponseSuccess(req, data)
}

func OnGetGameList(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	checkFields := []string{
		define.WebBusinessId,
		define.WebLang,
	}
	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	rsp := internal.OnGetGameListReq(&rpc_protos.GetGameListReq{
		BusinessID: str_conv.ToUint32(kv[define.WebBusinessId]),
		Lang:       kv[define.WebLang],
	})
	if rsp.Code != error_code.ErrorCodeNoError {
		ResponseFailed(req, rsp.Code)
	} else {
		ResponseSuccess(req, rsp.GameList)
	}
}

type GameRecordSum struct {
	Cost   int64 `gorm:"column:cost"`
	Reward int64 `gorm:"column:reward"`
}

func OnGetGameLogList(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	checkFields := []string{
		define.WebUserId,
		define.WebGameKind,
		define.WebBeginTime,
		define.WebEndTime,
		define.WebPageSize,
		define.WebPage,
		define.WebScoreType,
	}
	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	cfgScore, ok := cache.GetCfgScoreType(str_conv.ToUint32(kv[define.WebScoreType]))
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy)
		return
	}

	page := int(str_conv.ToInt64(kv[define.WebPage]))
	pageSize := int(str_conv.ToInt64(kv[define.WebPageSize]))
	bt := str_conv.ToInt64(kv[define.WebBeginTime])
	et := str_conv.ToInt64(kv[define.WebEndTime])
	bTime := time.Unix(bt, 0)
	eTime := time.Unix(et, 0)
	cli := db.GetDumper()

	rs := make([]db_meta.GameRecordLog, pageSize)
	rs1 := rs[:0]
	rs2 := rs[:0]

	off := page * pageSize
	count := int64(0)
	rsBase := db_meta.GameRecordLog{
		RecordTime: bt,
	}
	reBase := db_meta.GameRecordLog{
		RecordTime: et,
	}
	where := rsBase.WhereRecordBetween()
	whereParams := []any{bt, et}
	uid := kv[define.WebUserId]
	gameKind := kv[define.WebGameKind]

	if uid != "" {
		where = strings.Join([]string{where, rsBase.WherePlayer()}, " AND ")
		whereParams = append(whereParams, str_conv.ToUint64(uid))
	}

	if gameKind != "" {
		where = strings.Join([]string{where, rsBase.WhereGame()}, " AND ")
		whereParams = append(whereParams, str_conv.ToUint32(gameKind))
	}

	log.GetLogger().InfoPrintf("where:%s  param:%v", where, whereParams)
	grs1 := GameRecordSum{}
	if time.IsSameMonth(bTime, eTime) {
		y := cli.Table(rsBase.TableName()).Where(where, whereParams...)
		// 查询总条数
		y.Count(&count)
		y.Order("record_time desc").Limit(pageSize).Offset(off).Find(&rs2)

		y.Select("SUM(score_cost) as cost, SUM(score_reward) as reward").Scan(&grs1)
		// 查询结果
	} else {
		countS, countE := int64(0), int64(0)
		x := cli.Table(rsBase.TableName()).Where(where, whereParams...)
		y := cli.Table(reBase.TableName()).Where(where, whereParams...)
		// 查询总条数
		x.Count(&countS)
		y.Count(&countE)
		count = countS + countE

		// 查询B表总条数
		if off < int(countE) {
			y.Order("record_time desc").Limit(pageSize).Offset(off).Find(&rs2)
		}
		// 根据结果数量判断是否查询A表
		if len(rs2) < pageSize && countS > 0 {
			pz := pageSize - len(rs2)
			rs1 = rs[len(rs2):]
			x.Order("record_time desc").Limit(pz).Find(&rs1)
		}

		grs2 := GameRecordSum{}
		x.Select("SUM(score_cost) as cost, SUM(score_reward) as reward").Scan(&grs1)
		y.Select("SUM(score_cost) as cost, SUM(score_reward) as reward").Scan(&grs2)
		grs1.Cost += grs2.Cost
		grs1.Reward += grs2.Reward
	}
	data := map[string]any{
		"exchange": cfgScore.Exchange,
		"count":    count,
		"cost":     grs1.Cost,
		"reward":   grs1.Reward,
		"log_list": rs,
	}
	ResponseSuccess(req, data)
}

func OnGetGameLogInfo(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	checkFields := []string{
		define.WebUserId,
		define.WebLogID,
		define.WebTimeStamp,
		define.WebScoreType,
	}
	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	cfgScore, ok := cache.GetCfgScoreType(str_conv.ToUint32(kv[define.WebScoreType]))
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy)
		return
	}

	rs := db_meta.GameRecordLog{
		RecordTime: str_conv.ToInt64(kv[define.WebTimeStamp]),
	}

	cli := db.GetDumper()
	cli.Table(rs.TableName()).Where(rs.WhereLogID(), kv[define.WebLogID]).Find(&rs)
	if str_conv.ToUint64(kv[define.WebUserId]) != rs.UserID {
		ResponseFailed(req, error_code.ErrorCodeRequestNotAuth)
		return
	}

	data := map[string]any{
		"exchange": cfgScore.Exchange,
		"log_info": rs,
	}
	ResponseSuccess(req, data)
}

func OnGetPlayerScoreInfo(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	RspScore := "score"
	checkFields := []string{
		define.WebAccount,
		define.WebBusinessId,
	}

	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	userID, ok := cache.GetAccountID(kv[define.WebAccount], str_conv.ToUint32(kv[define.WebBusinessId]))
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeAccountIsNotExist)
		return
	}

	protoc, body := PbMsgHelper.PbMsgToRpcMsg(&rpc_protos.GetPlayerScoreReq{})
	rsp := e3dds.TakeResponse()
	defer e3dds.FreeResponse(rsp)
	err := behavior.Call(define.ServicePlayer, str_conv.ToString(userID), protoc, body, rsp)
	if err != nil {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy, err.Error())
		return
	}
	rspMsg := &rpc_protos.GetPlayerScoreRsp{}
	_ = proto.Unmarshal(rsp.GetBody(), rspMsg)
	data := map[string]any{
		RspScore: rspMsg.Info.Score,
	}
	ResponseSuccess(req, data)
}

func OnGetGameURL(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string, cipher crypto.Cipher) {
	checkFields := []string{
		define.WebBusinessId,
		define.WebGuest,
		define.WebLang,
		define.WebGameKind,
	}
	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	bid := str_conv.ToUint32(kv[define.WebBusinessId])
	isGuest := str_conv.ToBool(kv[define.WebGuest])
	userID := define.UserIDType(0)

	if !isGuest {
		if ac, ok := kv[define.WebAccount]; !ok {
			ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
			return
		} else if userID, ok = cache.GetAccountID(ac, bid); !ok {
			ResponseFailed(req, error_code.ErrorCodeAccountIsNotExist)
			return
		}
	}
	businessInfo, ok := cache.GetBusinessInfo(bid)
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeBusinessIsNotExist)
		return
	}

	cfgGameGroup, ok := cache.GetGameGroup(businessInfo.GameGroupID)
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy)
		return
	}

	toGameKindID := str_conv.ToUint32(kv[define.WebGameKind])
	ok = false
	for _, meta := range cfgGameGroup.List {
		if meta.GameKindID == toGameKindID {
			ok = true
			break
		}
	}

	if !ok {
		ResponseFailed(req, error_code.ErrorCodeEnterTheGameIsNotAuth)
		return
	}

	cfgScore, ok := cache.GetCfgScoreType(businessInfo.ScoreType)
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy)
		return
	}

	msg := rpc_protos.LoginGetTokenReq{}
	msg.UserID = userID
	msg.IsGuest = str_conv.ToBool(kv[define.WebGuest])
	rsp := internal.OnLoginGetTokenReq(&msg)

	if rsp.Code != error_code.ErrorCodeNoError {
		ResponseFailed(req, rsp.Code)
		return
	}
	//todo 检查商人限红
	//if params.AgentInfo.UsedMoneyLimit >= params.AgentInfo.MoneyLimit && params.AgentInfo.MoneyLimit != 0 && params.AgentInfo.AutoKick == 1 {
	//	ResponseFailed(req, error_code.ErrorCodeBusinessHasRestricted)
	//	return
	//}
	gameServerUrl := viper.GetStringSlice("api.game_server")
	if len(gameServerUrl) == 0 {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy)
		return
	}

	gameHistoryUrl := viper.GetStringSlice("api.history")
	if len(gameHistoryUrl) == 0 {
		ResponseFailed(req, error_code.ErrorCodeServiceBusy)
		return
	}

	urlParams := meta.GameURLParams{
		Lang:        kv[define.WebLang],
		MoneyType:   businessInfo.ScoreType,
		Rate:        cfgScore.Exchange,
		ServerID:    kv[define.WebGameKind],
		GameUrl:     gameServerUrl,
		HistoryUrl:  gameHistoryUrl,
		Token:       rsp.Token,
		MoneyBag:    businessInfo.BagType,
		LogoGroupID: businessInfo.LogoGroupID,
		Mark:        businessInfo.Mark,
	}

	token, err := misc.ParseGameUrlToken(cipher, &urlParams)
	if err != nil {
		ResponseFailed(req, error_code.ErrorCodeEncryptFailed)
		return
	}

	clientWebUrl := viper.GetString("api.client_web")
	url := fmt.Sprintf("%s/%v/web-mobile/?lang=%s&token=%s", clientWebUrl, toGameKindID, kv[define.WebLang], token)
	ResponseSuccess(req, url)
}

func OnModifyPlayerCtrl(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	SrcCtrlJson := "ctrl_json"
	checkFields := []string{
		define.WebUserId,
		SrcCtrlJson,
		define.WebAdminId,
	}
	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	userIDStr := kv[define.WebUserId]
	ctrlJsonStr := kv[SrcCtrlJson]
	adminIDStr := kv[define.WebAdminId]
	ctrlJs, ok := misc.VerifyPlayerCtrlJson(ctrlJsonStr)
	if !ok {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	msg := rpc_protos.ModifyPlayerCtrlCast{
		UserID: str_conv.ToUint64(userIDStr),
		OpFrom: define.DotCtrlOpFromBack,
		OpID:   adminIDStr,
	}

	for _, v := range ctrlJs {
		msg.Ctrl = append(msg.Ctrl, &rpc_protos.DotCtrlMeta{Level: int32(v[0].(float64)), Score: define.GameScore(v[1].(float64))})
	}
	protoc, body := PbMsgHelper.PbMsgToRpcMsg(&msg)
	behavior.Cast(define.ServicePlayer, userIDStr, protoc, body)
	ResponseSuccess(req)
}

func OnAddAutoCtrl(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	var (
		SrcStatus           = "status"
		SrcTriggerRate      = "trigger_rate"
		SrcCtrlJson         = "ctrl_json"
		SrcFirstLoginTime   = "first_login_time"
		SrcAvgBetScoreMin   = "avg_bet_score_min"
		SrcAvgBetScoreMax   = "avg_bet_score_max"
		SrcTotalWinScore    = "total_win_score"
		SrcTotalRound       = "total_round"
		SrcTodayWinScore    = "today_win_score"
		SrcTodayRound       = "today_round"
		SrcRechargeScoreMin = "recharge_score_min"
		SrcRechargeScoreMax = "recharge_score_max"
		SrcTotalCtrlTimes   = "total_ctrl_times"
		SrcTodayCtrlTimes   = "today_ctrl_times"
	)
	checkFields := []string{
		define.WebBusinessId,
		define.WebScoreType,
		SrcStatus,
		SrcTriggerRate,
		SrcCtrlJson,
		SrcFirstLoginTime,
		SrcAvgBetScoreMin,
		SrcAvgBetScoreMax,
		SrcTotalWinScore,
		SrcTotalRound,
		SrcTodayWinScore,
		SrcTodayRound,
		SrcRechargeScoreMin,
		SrcRechargeScoreMax,
		SrcTotalCtrlTimes,
		SrcTodayCtrlTimes,
	}

	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}
	if !misc.VerifyAutoCtrlJson(kv[SrcCtrlJson]) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	protoc, body := PbMsgHelper.PbMsgToRpcMsg(&rpc_protos.AddAutoCtrlCast{
		Bid:              str_conv.ToUint32(kv[define.WebBusinessId]),
		ScoreType:        str_conv.ToUint32(kv[define.WebScoreType]),
		Status:           str_conv.ToUint32(kv[SrcStatus]),
		TriggerRate:      str_conv.ToUint32(kv[SrcTriggerRate]),
		CtrlJson:         kv[SrcCtrlJson],
		FirstLoginTime:   str_conv.ToInt64(kv[SrcFirstLoginTime]),
		AvgBetScoreMin:   str_conv.ToInt64(kv[SrcAvgBetScoreMin]),
		AvgBetScoreMax:   str_conv.ToInt64(kv[SrcAvgBetScoreMax]),
		TotalWinScore:    str_conv.ToInt64(kv[SrcTotalWinScore]),
		TotalRound:       str_conv.ToInt64(kv[SrcTotalRound]),
		TodayWinScore:    str_conv.ToInt64(kv[SrcTodayWinScore]),
		TodayRound:       str_conv.ToInt64(kv[SrcTodayRound]),
		RechargeScoreMin: str_conv.ToInt64(kv[SrcRechargeScoreMin]),
		RechargeScoreMax: str_conv.ToInt64(kv[SrcRechargeScoreMax]),
		TotalCtrlTimes:   str_conv.ToInt64(kv[SrcTotalCtrlTimes]),
		TodayCtrlTimes:   str_conv.ToInt64(kv[SrcTodayCtrlTimes]),
	})

	behavior.Cast(define.ServiceMgrAutoDotCtrl, "", protoc, body)

	ResponseSuccess(req)
}

func OnDelAutoCtrl(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	SrcCfgID := "cfg_id"
	checkFields := []string{
		SrcCfgID,
	}

	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	broadcast.PushToService(define.ServiceMgrAutoDotCtrl, &rpc_protos.DelAutoCtrlBroadcast{
		CfgId: str_conv.ToUint32(kv[SrcCfgID]),
	})
	ResponseSuccess(req)
}

func OnModifyAutoCtrl(behavior e3dds.Behavior, req e3dds.Request, kv map[string]string) {
	var (
		SrcCfgID            = "cfg_id"
		SrcStatus           = "status"
		SrcTriggerRate      = "trigger_rate"
		SrcCtrlJson         = "ctrl_json"
		SrcFirstLoginTime   = "first_login_time"
		SrcAvgBetScoreMin   = "avg_bet_score_min"
		SrcAvgBetScoreMax   = "avg_bet_score_max"
		SrcTotalWinScore    = "total_win_score"
		SrcTotalRound       = "total_round"
		SrcTodayWinScore    = "today_win_score"
		SrcTodayRound       = "today_round"
		SrcRechargeScoreMin = "recharge_score_min"
		SrcRechargeScoreMax = "recharge_score_max"
		SrcTotalCtrlTimes   = "total_ctrl_times"
		SrcTodayCtrlTimes   = "today_ctrl_times"
	)
	checkFields := []string{
		SrcCfgID,
		SrcStatus,
		SrcTriggerRate,
		SrcCtrlJson,
		SrcFirstLoginTime,
		SrcAvgBetScoreMin,
		SrcAvgBetScoreMax,
		SrcTotalWinScore,
		SrcTotalRound,
		SrcTodayWinScore,
		SrcTodayRound,
		SrcRechargeScoreMin,
		SrcRechargeScoreMax,
		SrcTotalCtrlTimes,
		SrcTodayCtrlTimes,
	}

	if !misc.VerifyHttpFields(checkFields, kv) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	if !misc.VerifyAutoCtrlJson(kv[SrcCtrlJson]) {
		ResponseFailed(req, error_code.ErrorCodeProtocolDataNotVerify)
		return
	}

	broadcast.PushToService(define.ServiceMgrAutoDotCtrl, &rpc_protos.ModifyAutoCtrlBroadcast{
		CfgId:            str_conv.ToUint32(kv[SrcCfgID]),
		Status:           str_conv.ToUint32(kv[SrcStatus]),
		TriggerRate:      str_conv.ToUint32(kv[SrcTriggerRate]),
		CtrlJson:         kv[SrcCtrlJson],
		FirstLoginTime:   str_conv.ToInt64(kv[SrcFirstLoginTime]),
		AvgBetScoreMin:   str_conv.ToInt64(kv[SrcAvgBetScoreMin]),
		AvgBetScoreMax:   str_conv.ToInt64(kv[SrcAvgBetScoreMax]),
		TotalWinScore:    str_conv.ToInt64(kv[SrcTotalWinScore]),
		TotalRound:       str_conv.ToInt64(kv[SrcTotalRound]),
		TodayWinScore:    str_conv.ToInt64(kv[SrcTodayWinScore]),
		TodayRound:       str_conv.ToInt64(kv[SrcTodayRound]),
		RechargeScoreMin: str_conv.ToInt64(kv[SrcRechargeScoreMin]),
		RechargeScoreMax: str_conv.ToInt64(kv[SrcRechargeScoreMax]),
		TotalCtrlTimes:   str_conv.ToInt64(kv[SrcTotalCtrlTimes]),
		TodayCtrlTimes:   str_conv.ToInt64(kv[SrcTodayCtrlTimes]),
	})
	ResponseSuccess(req)
}
